package br.com.wai2008.client.wireless;

import java.io.BufferedReader;

import br.com.wai2008.client.system.SystemCommand;

/**
 * This class calls a system command execution which gets the
 * wireless signals that the machine's device could feel.<br>
 * This class only implements an execution of Linux system commands. In order
 * to perform the correct execution, you must give 'sudo' access
 * without password to the user who will execute these command. 
 * 
 * @since 
 * 		September, 2008.
 * 
 * @version
 * 		WAI2008 - version 1.0
 * 
 * @author 
 * 		Andre Romero Goncales
 */
public class WirelessSignal {

	/**
	 * Calls an execution of 'iwlist' command that returns
	 * all wireless signals the device could feel.<br>
	 * The command executed is 'sudo iwlist wlan0 scan'.<br>
	 * In order to correctly execute this system command, give 'sudo'
	 * access to the user who will execute this command.
	 * 
	 * @see
	 * 		br.com.wai2008.client.system.SystemCommand
	 * 
	 * @return
	 * 		The system command execution for 'iwlist' in a buffer or <b>null</>
	 * 		if an error occurs.
	 */
	public static BufferedReader getSignal() {
		System.out.println("[WirelessSignal] Getting wireless signal...");
		String[] getIwlist = new String[]{"sudo", "iwlist", "wlan0", "scan"};
		BufferedReader buffer = SystemCommand.executeSystemCommand(getIwlist);
		//DEBUG
		//WAISignalsGraphic.setSignals(buffer);
		return buffer;
	}
}
